package com.zxy.jediscluster;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

/**
 * @author : zhangxuyuan
 * @Project: jediscluster
 * @Package com.zxy.jediscluster
 * @date Date : 2021年03月30日 16:27
 */
public class JedisClusterApp {
    public static void main(String[] args) {
        JedisPoolConfig config = new JedisPoolConfig();
        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("192.168.2.136", 6379));
        jedisClusterNode.add(new HostAndPort("192.168.2.136", 6380));
        jedisClusterNode.add(new HostAndPort("192.168.2.136", 6381));
        jedisClusterNode.add(new HostAndPort("192.168.2.136", 6382));
        jedisClusterNode.add(new HostAndPort("192.168.2.136", 6383));
        jedisClusterNode.add(new HostAndPort("192.168.2.136", 6384));
        JedisCluster jcd = new JedisCluster(jedisClusterNode, config);
        String zhangfei = jcd.set("name:001", "zhangfei");
        System.out.println(zhangfei);
        String value = jcd.get("name:001");
        System.out.println(value);
    }
}
